package com.crm.controller;

import com.crm.dto.TransferDto;
import com.crm.entity.Transfer;
import com.crm.entity.User;
import com.crm.result.ActivityResult;
import com.crm.result.PageResult;
import com.crm.result.Result;
import com.crm.service.TransferService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/transfer")
@Slf4j
public class TransferController {
    @Autowired
    private TransferService transferService;

    @GetMapping("/list")
    public ActivityResult<List<User>> pageTransfer(TransferDto transferDto) {
        PageResult res = transferService.getTransferPageWithConditions(transferDto);
        return ActivityResult.success("查询成功", null, res.getRows(), res.getTotal());
    }


    //转派
    @PutMapping("/assignment/{typeId}/{id}/{userId}")
    public Result transfer(@PathVariable("typeId")Integer typeId,@PathVariable("id")Integer id,@PathVariable("userId")Integer userId){
        transferService.setTransfer(typeId, id, userId);
        return Result.success();
    }



}
